package cn.hp.service.impl;

import cn.hp.entity.Menu;
import cn.hp.mapper.MenuMapper;
import cn.hp.service.MenuService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class MenuServiceImpl implements MenuService {

    @Autowired
    private MenuMapper menuMapper;

    @Override
    public List<Menu> selectMenu(Menu menu) {
        return menuMapper.findMenu(menu);
    }

    @Override
    public PageInfo<Menu> selectMenu(Menu menu, Integer page, Integer limit) {
        PageHelper.startPage(page ,limit);
        List<Menu>list= menuMapper.findMenu(menu);
        return new PageInfo<>(list);
    }

    @Override
    public int insertMenu(Menu menu) {
        return menuMapper.insertMenu(menu);
    }

    @Override
    public int updateMenu(Menu menu) {
        return menuMapper.updateMenu(menu);
    }

    @Override
    public int deleteMenuById(Integer id) {
        return menuMapper.deleteMenuById(id);
    }
}
